package com.bootdo.system.service.impl;

import com.bootdo.system.service.LoginService;
import com.bootdo.system.shiro.ShiroLoginToken;
import com.bootdo.system.vo.LoginUser;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Service;
import org.springframework.ui.ModelMap;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @program: bootdo
 * @description:
 * @author: wfy
 * @create: 2018-09-13 20:18
 */
@Service
public class LoginServiceImpl implements LoginService{

    @Override
    public void login(LoginUser loginUser, HttpServletRequest request, HttpServletResponse response, ModelMap model){
        ShiroLoginToken token = new ShiroLoginToken(loginUser.getUsername(), loginUser.getXstr());
        Subject subject = SecurityUtils.getSubject();
        subject.login(token);
    }
}
